package main

import (
	"time"
	"runtime"
	"gim/comm"
	"gim/storage"
	"flag"
	log "github.com/golang/glog"
)

func main() {
	root := flag.String("-R", "/tmp", "/tmp")//db文件目录
	host := flag.String("-H", "127.0.0.1:8088", "127.0.0.1:8088")//db文件目录
	flag.Parse()

	log.Info("gim storage start....\n")
	// Set max routine
	max := runtime.NumCPU()
	runtime.GOMAXPROCS(max)

	// start http listen.
	storage.StartStorage(*root, *host)
	
	// init process
	// sleep one second, let the listen start
	time.Sleep(time.Second)
	// if err = common.InitProcess(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
	// 	fmt.Printf("common.InitProcess() error(%v)", err)
	// 	return
	// }
	// init signals, block wait signals
	signalCH := comm.InitSignal()
	comm.HandleSignal(signalCH)
	log.Info("gim storage stoped\n")
}